//
//  UIView+CrazyView.m
//  JF_New_DYKT
//
//  Created by 陈雷 on 2017/8/25.
//  Copyright © 2017年 陈雷. All rights reserved.
//

#import "UIView+CrazyView.h"

@implementation UIView (CrazyView)

- (void)setX:(CGFloat)X{
    self.frame = CGRectMake(X, self.frame.origin.y, self.frame.size.width, self.frame.size.height);
}

- (void)setY:(CGFloat)Y{
    self.frame = CGRectMake(self.frame.origin.x, Y, self.frame.size.width, self.frame.size.height);
}


- (void)setWidth:(CGFloat)Width{
    self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, Width, self.frame.size.height);
}


- (void)setHeight:(CGFloat)Height{
    self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, Height);
}

- (void)setCenterX:(CGFloat)CenterX{
    self.center = CGPointMake(CenterX, self.center.y);
}


- (void)setCenterY:(CGFloat)CenterY{
    self.center = CGPointMake(self.center.x, CenterY);
}

- (CGFloat)X{
    CGFloat x = self.frame.origin.x;
    return x;
}

- (CGFloat)Y{
    CGFloat y = self.frame.origin.y;
    return y;
}

- (CGFloat)Width{
    CGFloat width = self.frame.size.width;
    return width;
}

- (CGFloat)Height{
    CGFloat height = self.frame.size.height;
    return height;
}

- (CGFloat)CenterX{
    CGFloat centerX = self.center.x;
    return centerX;
}

- (CGFloat)CenterY{
    CGFloat centerY = self.center.y;
    return centerY;
}

- (UIViewController *)viewController
{
    UIResponder *next = self.nextResponder;
    do {
        if ([next isKindOfClass:[UIViewController class]]) {
            return (UIViewController *)next;
        }
        next = next.nextResponder;
    } while (next);
    
    return nil;
}

@end
